/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author ODHeroes
 */
@Entity
@Table(name = "login")
@NamedQueries({
    @NamedQuery(name = "Login.findAll", query = "SELECT l FROM Login l"),
    @NamedQuery(name = "Login.findByNick", query = "SELECT l FROM Login l WHERE l.nick = :nick"),
    @NamedQuery(name = "Login.findByPassword", query = "SELECT l FROM Login l WHERE l.password = :password"),
    @NamedQuery(name = "Login.findByNombres", query = "SELECT l FROM Login l WHERE l.nombres = :nombres"),
    @NamedQuery(name = "Login.findByApellidos", query = "SELECT l FROM Login l WHERE l.apellidos = :apellidos"),
    @NamedQuery(name = "Login.findByDireccion", query = "SELECT l FROM Login l WHERE l.direccion = :direccion"),
    @NamedQuery(name = "Login.findByProfesion", query = "SELECT l FROM Login l WHERE l.profesion = :profesion")})
public class Login implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1024)
    @Column(name = "nick")
    private String nick;
    @Size(max = 1024)
    @Column(name = "password")
    private String password;
    @Size(max = 1024)
    @Column(name = "nombres")
    private String nombres;
    @Size(max = 1024)
    @Column(name = "apellidos")
    private String apellidos;
    @Size(max = 1024)
    @Column(name = "direccion")
    private String direccion;
    @Size(max = 1024)
    @Column(name = "profesion")
    private String profesion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "nick")
    private Collection<Establishments> establishmentsCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "nick")
    private Collection<Publicaciones> publicacionesCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "nick")
    private Collection<Perfiles> perfilesCollection;
    @OneToMany(mappedBy = "nick")
    private Collection<Products> productsCollection;

    public Login() {
    }

    public Login(String nick) {
        this.nick = nick;
    }

    public String getNick() {
        return nick;
    }

    public void setNick(String nick) {
        this.nick = nick;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getNombres() {
        return nombres;
    }

    public void setNombres(String nombres) {
        this.nombres = nombres;
    }

    public String getApellidos() {
        return apellidos;
    }

    public void setApellidos(String apellidos) {
        this.apellidos = apellidos;
    }

    public String getDireccion() {
        return direccion;
    }

    public void setDireccion(String direccion) {
        this.direccion = direccion;
    }

    public String getProfesion() {
        return profesion;
    }

    public void setProfesion(String profesion) {
        this.profesion = profesion;
    }

    public Collection<Establishments> getEstablishmentsCollection() {
        return establishmentsCollection;
    }

    public void setEstablishmentsCollection(Collection<Establishments> establishmentsCollection) {
        this.establishmentsCollection = establishmentsCollection;
    }

    public Collection<Publicaciones> getPublicacionesCollection() {
        return publicacionesCollection;
    }

    public void setPublicacionesCollection(Collection<Publicaciones> publicacionesCollection) {
        this.publicacionesCollection = publicacionesCollection;
    }

    public Collection<Perfiles> getPerfilesCollection() {
        return perfilesCollection;
    }

    public void setPerfilesCollection(Collection<Perfiles> perfilesCollection) {
        this.perfilesCollection = perfilesCollection;
    }

    public Collection<Products> getProductsCollection() {
        return productsCollection;
    }

    public void setProductsCollection(Collection<Products> productsCollection) {
        this.productsCollection = productsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nick != null ? nick.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Login)) {
            return false;
        }
        Login other = (Login) object;
        if ((this.nick == null && other.nick != null) || (this.nick != null && !this.nick.equals(other.nick))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Model.Login[ nick=" + nick + " ]";
    }
    
}
